package com.visikard.item;

import java.io.Serializable;

import org.json.JSONObject;

public class ItemPlaceGoogle implements Serializable {

	private static final long serialVersionUID = 10998L;

	private String name;
	private String latitude;
	private String longitude;

	long countryId;
	String adminCode1;
	String countryName;
	String fclName;
	String countryCode;
	String fcodeName;
	String toponymName;
	String fcl;
	String fcode;
	long geonameId;
	String adminName1;
	int population;
	String formattedAddress;
	String zipCode = "";

	public ItemPlaceGoogle() {
	}

	public ItemPlaceGoogle(String name, String lat, String lon) {
		this.name = name;
		this.latitude = lat;
		this.longitude = lon;
	}

	public ItemPlaceGoogle(String name, String lat, String lon, String zipCode) {
		this.name = name;
		this.latitude = lat;
		this.longitude = lon;
		this.zipCode = zipCode;
	}

	public ItemPlaceGoogle(JSONObject job) {
		if (job == null) {
			return;
		}
		else {
			try {
				latitude = job.optString("latitude", "");
				if (latitude.equals("null")) {
					latitude = "";
				}
				if (latitude.length() <= 0)
					latitude = job.optString("lat", "");

				longitude = job.optString("longitude", "");
				if (longitude.equals("null")) {
					longitude = "";
				}
				if (longitude.length() <= 0)
					longitude = job.optString("lng", "");

				name = job.optString("cityAddress", "");
				if (name.equals("null")) {
					name = "";
				}
				if (job.has("name")) {
					name = job.optString("name");
				}

				countryId = job.optLong("countryId", -1);
				adminCode1 = job.optString("adminCode1");
				countryName = job.optString("countryName");
				fclName = job.optString("fclName");
				countryCode = job.optString("countryCode");
				fcodeName = job.optString("fcodeName");
				toponymName = job.optString("toponymName");
				fcl = job.optString("fcl");
				fcode = job.optString("fcode");
				geonameId = job.optLong("geonameId", -1);
				adminName1 = job.optString("adminName1");
				population = job.optInt("population", -1);
			}
			catch (Exception e) {
				e.printStackTrace();
			}
		}
	}

	public String getName() {
		if (name == null)
			return "";
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public void setLocation(String lat, String lng) {
		latitude = lat;
		longitude = lng;
	}

	public String getLatitude() {
		return latitude;
	}

	public String getLongitude() {
		return longitude;
	}

	public long getCountryId() {
		return countryId;
	}

	public String getFormattedAddress() {
		if (formattedAddress == null)
			return "";
		return formattedAddress;
	}

	public void setFormattedAddress(String add) {
		this.formattedAddress = add;
	}

	public String getAdminCode1() {
		if (adminCode1 == null)
			return "";
		return adminCode1;
	}

	public String getCountryName() {
		if (countryName == null)
			return "";
		return countryName;
	}

	public String getFclName() {
		return fclName;
	}

	public String getCountryCode() {
		if (countryCode == null)
			return "";
		return countryCode;
	}

	public void setCountryCode(String cc) {
		countryCode = cc;
	}

	public String getFcodeName() {
		return fcodeName;
	}

	public String getToponymName() {
		return toponymName;
	}

	public String getFcl() {
		return fcl;
	}

	public String getFcode() {
		return fcode;
	}

	public long getGeonameId() {
		return geonameId;
	}

	public String getAdminName1() {
		return adminName1;
	}

	public int getPopulation() {
		return population;
	}

	public String getZipCode() {
		if (zipCode == null)
			return "";
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	public void setCountryName(String countryName) {
		this.countryName = countryName;
	}

	public void setAdminCode1(String adminCode1) {
		this.adminCode1 = adminCode1;
	}

	public void setAdminName1(String adminName1) {
		this.adminName1 = adminName1;
	}

}
